<div class="heading">
    <div class="left_heading"></div>
                                
    <div class="content_heading">
        <h3>Quản lý tin voucher</h3>
    </div>
                                
    <div class="right_heading"></div>
</div><!-- End .heading -->

<div class="main_content">
    <div class="table_form">
        <form class="search_form" name="search_form" action="product/search" method="get">
        Tìm kiếm: 
        <input class="input" type="text" name="keyword" value="<?php echo $this->searchValue; ?>" />
        <input class="button" type="submit" name="search" value="Tìm kiếm" />
        <span class="msg"><?php echo $this->errorSearch; ?></span>
        </form>
        
        <form class="list_cat_form" action="" method="post">
        <div style="float: left; margin-top: 10px;">
            <img src="<?php echo $this->baseUrl('/public/templates/mod/images/tr_hot.jpg'); ?>" width="20px" height="20px" /> Tin nóng
            <img style="margin-left: 10px;" src="<?php echo $this->baseUrl('/public/templates/mod/images/tr_expiry.jpg'); ?>" width="20px" height="20px" /> Đã hết hạn
        </div>
        
        <div style="float: right;">
        	<p id="add_form">Số lượng: <span class="msg"><?php echo $this->total; ?></span> tin voucher</p>
	        <?php echo $this->formSubmit('add', 'Thêm mới', array('class' => 'button', 'id' => 'add_form')); ?>
	        <?php echo $this->formSubmit('addhot', 'Tin nóng', array('class' => 'button', 'id' => 'add_form', 'onclick' => 'return addhot_alert()')); ?>
            <?php echo $this->formSubmit('refresh', 'Làm mới', array('class' => 'button', 'id' => 'add_form')); ?>
	        <?php echo $this->formSubmit('delete', 'Xóa', array('class' => 'button', 'id' => 'del_form', 'onclick' => 'return remove_alert()')); ?>
        </div>                   
        <table class="table_style">
            <tr class="head_table">
                <td width="200px">Tên voucher</td>
                <td width="40">Ảnh</td>
                <td width="80">Vùng miền</td>
                <td width="80px">Danh mục</td>
                <td width="100px">Nguồn tin</td>
                <td width="80px">Trạng thái</td>
                <td class="tools">&nbsp;</td>
                <td class="tools">&nbsp;</td>
                <td class="tools"><?php echo $this->formCheckbox('check_all', null, array('id' => 'check_all', 'onClick' => 'checkAll()')); ?></td>
            </tr>
            <?php
                $product = new ModCp_Model_Product();
                $actualDate = time();
                $dateFormat = "Y-m-d H:i:s";
            	if(count($this->data) > 0) :
            	foreach($this->data as $value) :
                    $targetYear  = $value['expiry_year'];
                	$targetMonth = $value['expiry_month'];
                	$targetDay   = $value['expiry_day'];
                	$targetHour  = $value['expiry_hour'];
                	$targetMinute= $value['expiry_minute'];
                	$targetSecond= $value['expiry_second'];
                    
                    $targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
                    
                    $secondsDiff = $targetDate - $actualDate;
                    
                    $remainingDay     = floor($secondsDiff/60/60/24);
                ?>
            <?php if(($remainingDay +1) <= 0) : ?>
            <tr class="records" style="background-color: #FF0000;">
            <?php elseif($value['hot'] == '1') : ?>
            <tr class="records" style="background-color: #FFFF00;">
            <?php else : ?>
            <tr class="records">
            <?php endif; ?>
                <td><?php echo $product->cut_string($value['product_name'], 80, 1); ?></td>
                <td><img src="<?php echo $this->baseUrl('/public/files/product/') . $value['product_image']; ?>" width="40px" height="40px" data-tooltip="sticky<?php echo $value['product_id']; ?>" /></td>
                <td><?php echo $value['area_name']; ?></td>
                <td><?php echo $value['cat_name']; ?></td>
                <td><?php echo $value['provider_name']; ?></td>
                <td>
                <?php 
                	if($value['status'] == 1)
                	{
                		echo 'Hiển thị';
                	}
                	else
                	{
                		echo 'Ẩn đi';
                	}
                ?></td>
                <td><a class="edit" title="Sửa" href="<?php echo $this->baseUrl('/mod-cp/product/edit?id=' . $value['product_id']); ?>"></a></td>
                <td><a class="remove" title="Xóa" onclick="return remove_alert()" href="<?php echo $this->baseUrl('/mod-cp/product/delete?id=' . $value['product_id']); ?>"></a></td>
                <td><?php echo $this->formCheckbox('check[]', $value['product_id']); ?></td>
            </tr>
            <?php 
                endforeach;
                else :
            ?>
            <tr class="records">
            	<td colspan="8">Hiện không có tin voucher nào</td>
            </tr>
            <?php endif; ?>
        </table>
        </form>
    </div>
    
    <div class="pagination">
        <?php echo $this->paginationControl($this->data, 'Sliding', 'product/pagination.phtml'); ?>
    </div>
    
    <div id="mystickytooltip" class="stickytooltip">
    	<?php 
            if(count($this->data) > 0) : 
            foreach($this->data as $value) :
        ?>
	    <div id="sticky<?php echo $value['product_id']; ?>" class="atip" style="width:auto; height:auto; text-align:center;">
	    	<img style="width: 250px; height: 250px; text-align:center;" src="<?php echo $this->baseUrl('/public/files/product/') . $value['product_image']; ?>">
	    </div>
	    <?php 
	    	endforeach;
	    	endif;
	    ?>
    </div>
</div><!-- End .main_content -->  